﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace ApplLogic.ApplClasses
{
    [Serializable]
    public class ApplPersonalDetails
    {
        private string m_Id;
        private string m_FirstName;
        private string m_LastName;
        private DateTime m_BirthDate;
        private string m_EmailAdress;
        private string m_UserName;
        private string m_Password;

        public string Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }

        public string FirstName
        {
            get { return m_FirstName; }
            set { m_FirstName = value; }
        }

        public string LastName
        {
            get { return m_LastName; }
            set { m_LastName = value; }
        }

        public DateTime BirthDate 
        {
            get { return m_BirthDate; } 
            set { m_BirthDate = value;} 
        }

        public string EmailAdress 
        {
            get { return m_EmailAdress; }
            set { m_EmailAdress = value; } 
        }

        public string UserName 
        {
            get { return m_UserName; }
            set { m_UserName = value; } 
        }

        public string Password 
        {
            get { return m_Password; }
            set { m_Password = value; } 
        }

        public string FullName
        {
            get { return m_FirstName + " " + m_LastName; }
        }

        public ApplPersonalDetails DeepClone()
        {
            MemoryStream ms = new MemoryStream();
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(ms, this);
            ms.Position = 0;
            ApplPersonalDetails obj = (ApplPersonalDetails)bf.Deserialize(ms);
            ms.Close();
            return obj;     
        }

        public override string ToString()
        {
            return
                string.Format("\n Full Name: {0}\n BirthDate: {1}\n Id: {2}\n Email: {3}\n UserName: {4}\n Password: {5}\n"
                              , FullName , m_BirthDate.ToShortDateString(), m_Id, m_EmailAdress,
                              m_UserName, m_Password);
        }
    }
}
